import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { LoginComponent } from './account/login/login.component';
import { HomeComponent } from './home/home.component';
import { DefaultComponent } from '../layout/default/default.component';
import { LayoutAccountComponent } from '../layout/layout-account/layout-account.component';
import { Error403Component } from './error/error403/error403.component';
import { Error404Component } from './error/error404/error404.component';
import { AppRouteGuard } from '@shared/common/auth/auth-route-app-guard';


const routes: Routes = [
  {
    path: '',
    component: DefaultComponent,
    data: { breadcrumb: '<i class="ag_home"></i>' },
    children: [
      { path: '', redirectTo: 'home', pathMatch: 'full' },
      { path: 'home', component: HomeComponent, canActivate: [AppRouteGuard], },
      // left nav
      { path: 'system', loadChildren: './system-config/system-config.module#SystemConfigModule' },
      { path: 'basic', loadChildren: './basic-data/basic-data.module#BasicDataModule' },
      { path: 'daily', loadChildren: './device-daily/device-daily.module#DeviceDailyModule' },
      { path: 'center', loadChildren: './center-regulation/center-regulation.module#CenterRegulationModule' },
      { path: 'report', loadChildren: './statistical-report/statistical-report.module#StatisticalReportModule' },
      { path: 'road', loadChildren: './road-monitoring/road-monitoring.module#RoadMonitoringModule' },
      { path: '403', component: Error403Component },
      { path: '404', component: Error404Component },
    ]
  },
  // account
  {
    path: 'account',
    component: LayoutAccountComponent,
    children: [
      { path: 'login', component: LoginComponent },
    ]
  },
  // 单页不包裹Layout
  // { path: '403', component: Error403Component },
  // { path: '404', component: Error404Component },
  // { path: '500', component: Exception500Component },
  { path: '**', redirectTo: '404' }
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class RouteRoutingModule { }
